package com.sll.hosptials.config;


public class Singleton {
//    使用volatile关键字防止指令重排
    private static volatile Singleton instance;

    private Singleton() {
        // 私有构造函数，防止外部直接实例化
    }

//    获取唯一可用的对象
    public static Singleton getInstance() {
        if (instance == null) {
            synchronized (Singleton.class) {
                if (instance == null) {
                    instance = new Singleton();
                }
            }
        }
        return instance;
    }
}
